//
//  JProductDetailTableCell.m
//  HeadIndustry
//
//  Created by jun on 2017/8/30.
//  Copyright © 2017年 jun. All rights reserved.
//

#import "JProductDetailTableCell.h"

@implementation JProductDetailTableCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        
        self.opaque = NO;
        self.backgroundColor = [UIColor whiteColor];

    }
    return self;
}

- (void)setUpView:(NSArray *)arr {
    
    _titleLabel = [YYLabel new];
    _titleLabel.top = 0;
    _titleLabel.left = 20;
    _titleLabel.size = CGSizeMake(kWindowW - 40, 40);
    _titleLabel.font = kFONT_TITLE(16);
    _titleLabel.textColor = kRGBColor(78, 78, 78);
    _titleLabel.textAlignment = NSTextAlignmentCenter;
    _titleLabel.numberOfLines = 0;
    _titleLabel.text = @"产品参数";
    [self addSubview:_titleLabel];
    
    CALayer *line1 = [CALayer layer];
    line1.contents = (__bridge id _Nullable)([UIImage imageNamed:@"pzh"].CGImage);
    line1.centerY = _titleLabel.centerY;
    line1.left = _titleLabel.width/2.0 - 80 ;
    line1.size = CGSizeMake(40, 1);
    [self.layer addSublayer:line1];
    
    CALayer *line2 = [CALayer layer];
    line2.contents = (__bridge id _Nullable)([UIImage imageNamed:@"pzh"].CGImage);
    line2.centerY = _titleLabel.centerY;
    line2.left = _titleLabel.width/2.0 + 80 ;
    line2.size = CGSizeMake(40, 1);
    [self.layer addSublayer:line2];

    if (arr.count > 0) {
        for (int i = 0; i < arr.count; i++) {
            YYLabel *titleLabel = [[YYLabel alloc]initWithFrame:CGRectMake(10, i * _heightView + 40, 100, _heightView)];
            titleLabel.numberOfLines = 0;
            titleLabel.textAlignment = NSTextAlignmentLeft;
            titleLabel.textColor = kRGBColor(152, 152, 152);
            titleLabel.font = kFONT_TITLE(16);
            titleLabel.text = arr[i][@"AttributeName"];
            [self addSubview:titleLabel];
            
            YYLabel *conTextLabel = [[YYLabel alloc]initWithFrame:CGRectMake(CGRectGetMaxX(titleLabel.frame) + 30, i * _heightView + 40, kWindowW - 150, _heightView)];
            conTextLabel.numberOfLines = 0;
            conTextLabel.textAlignment = NSTextAlignmentLeft;
            conTextLabel.textColor = [UIColor blackColor];
            conTextLabel.font = kFONT_TITLE(16);
            conTextLabel.text = arr[i][@"AttributeValue"];
            [self addSubview:conTextLabel];
            
            CALayer *line11 = [CALayer new];
            line11.frame = CGRectMake(10, CGRectGetMaxY(conTextLabel.frame) - 0.5, kWindowW - 20, 0.5);
            line11.backgroundColor = kRGBColor(223, 223, 223).CGColor;
            [self.layer addSublayer:line11];
            
        }
    }
    

}

- (void)setDataArr:(NSArray *)dataArr
{
    _dataArr = dataArr;
    [self setUpView:dataArr];
    
}

@end
